package com.example.myandroidapp1.service;

import java.util.Map;

import android.os.AsyncTask;

import com.example.myandroidapp1.entity.Gallery;
import com.example.myandroidapp1.factory.HttpClientFactory;
import com.example.myandroidapp1.gateway.HttpRestGateway;
import com.google.gson.GsonBuilder;

public class GalleryViewService extends AsyncTask<String, Integer, Gallery> {
	
	private Gallery getGallery(String url, Map<String, String> requestParameters) {
		Gallery gallery = null; 
		HttpRestGateway httpRestGateway = HttpClientFactory.getInstance();
		String response = httpRestGateway.makeGetCall(url, requestParameters);
		if(response != null){
			gallery = new GsonBuilder().create().fromJson(response, Gallery.class);
		}
		return gallery;
	}

	@Override
	protected Gallery doInBackground(String... urls) {
		String url = urls[0];
		Gallery gallery = getGallery(url, null);
		return gallery;
	}

}
